package com.yc.star.job;

import com.yc.star.entity.User;
import com.yc.star.mapper.UserMapper;
import com.yc.star.vo.RedisUtil;
import org.quartz.*;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * 任务查询所有用户存入缓存
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class UserJob implements Job {

    @Resource
    UserMapper userMapper;

    @Resource
    RedisUtil redisUtil;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        //context -定时任务上下文
        JobDetail jobDetail = context.getJobDetail();
        System.out.println("人物名字"+jobDetail.getKey().getName());
        List<User> userRedis = userMapper.selectList(null);
        redisUtil.set("userRedis",userRedis);
    }
}
